val list = List(1,2,3,4,5,7)

list.last

def f3[T] = ((_:List[T]).head) compose ((_:List[T]).reverse)

f3(list)



list(4-1)

@annotation.tailrec
def findByIndex[T](list:List[T],index:Int) : T = list match {
  case Nil => throw new IndexOutOfBoundsException()
  case head :: tails =>
    if (index < 1) throw new IndexOutOfBoundsException()
    if (index == 1) head else findByIndex(tails ,index - 1)
}

findByIndex(list,4)



//list.aggregate()
import scala.concurrent.Future
import scala.math._
0 to 100 by 2
(1 to 100 by 2).map(x=>x*x).sum
(0/:(0 to 100))((s,i)=>s+i%2*i*i)
1%2
Range(1, 100, 2).map(x => x * x).sum

import scala.concurrent.ExecutionContext.Implicits.global

//Future.sequence(Option(Future(0)))
//
